<?php

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \frontend\models\SignupForm */

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
use common\models\articles\Articles;
$this->title = '用户注册';
$this->params['breadcrumbs'][] = $this->title;
$ar = Articles::find()->where(['category_id'=>36])->one();
?>

<div id="Content">
    <h3 class="C_h3">账号注册：</h3>
    <div class="Liu">
        <img src="<?= yii::getAlias('@web');?>/images/Liu.png"><br>
        <div>
            <span>设置账号信息</span><span class="b">验证账号信息</span><span>注册成功</span>
        </div>
    </div>
    <div class="Zce">
        <div class="Zc_box">
            <p style="color:#c40400;">
                <?php
                if(\Yii::$app->getSession()->getFlash("error"))
                {
                    echo \Yii::$app->getSession()->getFlash("error");
                }
                ?>
            </p>
            <?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false]); ?>
            <p class="all_p"><label><font>*</font>电子邮箱：</label><input name="SignupForm[email]" placeholder="请输入电子邮箱" id="email" type="text"></p>
            <p class="all_p"><label><font>*</font>登录密码：</label><input name="SignupForm[password]" placeholder="请输入密码" id="pasw" type="text"></p>
            <p class="all_p"><label><font>*</font>确认登录密码：</label><input  placeholder="再次输入密码" id="paswd" type="text"></p>
            <p class="all_p"><label><font>*</font>验证码：</label>
                <input style="width:195px;" name="code" placeholder="验证码" id="yan" class="a" type="text">
                <?= Captcha::widget(['name'=>'code','captchaAction'=>'auth/captcha','imageOptions'=>['id'=>'login_code', 'title'=>'换一个', 'alt'=>'换一个'],'template'=>'{image}']);?>
            </p>
            <p class="p_a"><input id="tiao" type="checkbox"><span>我同意并已阅读<a href="#" style="color:#0066cc;">《XX协会服务协议》</a></span><div style="clear:both"></div></p>
            <p class="p_a"><input id="sub" class="Sbu" type="button" onclick="mytry()" value="立即提交"></p>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>
<script>

    function mytry(){
            var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var Pasw = $("#pasw").val();
            var Paswd = $("#paswd").val();
            var Yanzheng = $("#yan").val();
            var hasChk = $('#tiao').is(':checked');


            if ($("#email").val() == '' || !email_check.test($("#email").val())) {
                alert("请填写正确的邮箱！");
                return false;
            }

            if (Pasw == "") {
                alert("密码不能为空！");
                return false;
            }

            if (Paswd == "") {
                alert("请再次输入一遍密码！");
                return false;
            }

            if (Pasw != Paswd) {
                alert("两次密码输入不一致！");
                return false;
            }

            if (Yanzheng == "") {
                alert("验证码不能为空！");
                return false;
            }

            if (!hasChk) {
                alert("请阅读注册条款！");
                return false;
            }
        $('#login-form').submit();
        }

</script>
